<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>订单详细信息</title>
    {% include 'admin/common/header.html' %}
</head>
<style>

    .layui-input-block {
        line-height: 36px;
    }
</style>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">

                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">订单id</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{ wxorder.id }}" name="id" lay-verify="title"
                               autocomplete="off" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">订单状态</label>
                    <div class="layui-input-block">
                        {% if wxorder.order_price==1 %}
                            <span class='layui-badge layui-bg-green'>已完成</span>

                        {% elif wxorder.pay_status==1 and wxorder.order_price==0 %}
                            <span class='layui-badge layui-bg-green'>出货中</span>

                        {% elif wxorder.pay_status==0 %}
                            <span class='layui-badge layui-bg-green'>未支付</span>
                        {% else %}
                            <span class='layui-badge layui-bg-gray'>已取消</span>
                        {% endif %}
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">订单姓名</label>
                    <div class="layui-input-block">
                        <span class='layui-badge layui-bg-gray'>{{ wxuser.username }}</span>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">收货信息</label>
                    <div class="layui-input-block">
                        {% if wxorder.send_type==0 %}
                            <span class='layui-badge layui-bg-gray'>(取餐码){{ wxorder.code }}</span>
                        {% else %}
                            <span class='layui-badge layui-bg-gray'>(收货人){{ address.username }}</span>
                            <span class='layui-badge layui-bg-gray'>(手机号){{ address.phone }}</span>
                            <span class='layui-badge layui-bg-gray'>(地址){{ address.address }}</span>
                        {% endif %}

                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">商品信息</label>
                </div>

                <div class="layui-form-item">
                    <table class="layui-table">
                        <colgroup>
                            <col width="150">
                            <col width="200">
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>商品名称</th>
                            <th>商品编号</th>
                            <th>价格</th>
                            <th>数量</th>
                            <th>图片</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for good in goods %}
                        <tr>
                            <td>{{ good.gname }}</td>
                            <td>1</td>
                            <td>{{ good.price }}</td>
                            <td>1</td>
                            <td>
                                <img src="{{ good.gphoto }}">
                            </td>
                        </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>

</form>
{% include 'admin/common/footer.html' %}
<script>
    layui.use(['upload', 'form', 'jquery', 'dtree'], function () {
        let form = layui.form
        let $ = layui.jquery
        let dtree = layui.dtree
        let upload = layui.upload
        {#let imgpath = '{{ goods.gphoto }}'#}
        {#dtree.renderSelect({#}
        {#    elem: '#selectParent',#}
        {#    url: '/dept/tree',#}
        {#    method: 'get',#}
        {#    selectInputName: {nodeId: 'deptId', context: 'deptName'},#}
        {#    skin: 'layui',#}
        {#    dataFormat: 'list',#}
        {#    response: {treeId: 'deptId', parentId: 'parentId', title: 'deptName'},#}
        {#    selectInitVal: "{{ user.dept_id }}"#}
        {#//})#}

        //拖拽上传
        upload.render({
            elem: '#uptest'
            , url: '{{ url_for('goods.upphoto') }}' //此处用的是第三方的 http 请求演示，实际使用时改成您自己的上传接口即可。
            {#,url: 'https://httpbin.org/post'#}
            , exts: 'jpg|png|gif|bmp|jpeg'
            , done: function (res) {
                layer.msg('上传成功', {icon: 1});
                {#console.log(res.img)#}
                layui.$('#uploadDemoView').find('img').attr('src', res.data.src);
                imgpath = res.data.src
                console.log(imgpath)
                {#layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.files.file);#}
                console.log(res)
            }
        });

        form.on('submit(user-update)', function (data) {
            {#let roleIds = ''#}
            {#$('input[type=checkbox]:checked').each(function () {#}
            {#    roleIds += $(this).val() + ','#}
            {#//})#}
            {#roleIds = roleIds.substr(0, roleIds.length - 1)#}
            {#data.field.file = roleIds#}
            data.field.file = imgpath
            console.log(data.field)


            $.ajax({
                url: '/goods/update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
                            parent.layui.table.reload('user-table')
                        })
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000})
                    }
                }
            })
            return false
        })
    })
</script>
</body>
</html>